subroutine r1ai_t1am_fmi(r1, t1, &
              fmi, icore, fact)
!
use mod_ioff
use mod_orbit 
implicit none
!
real*8, intent(in) :: fact
real*4, intent(in) :: fmi(*)
real*4, intent(in) :: r1(*)
!
real*4, intent(inout) :: t1(*), icore(*)
!
integer :: i, j, a, b, nsize, nsizeaa, nsizebb
integer, external :: irpdso
real*8, external :: dnrm2, nrm2so
!this is to do r1(a,i) = r1(a,i) - t1(am)*fmi(mi)
nsizeaa = irpdso(1, vrta, popa, 1)
nsizebb = irpdso(1, vrtb, popb, 1)
!==AA
! write(6,*)'norm of aa 1 r1t1f', nrm2so(nsizeaa, r1(ifvo(1)), 1) 
! write(6,*)'norm of bb 1 r1t1f', nrm2so(nsizebb, r1(ifvo(2)), 1) 
 call VpqmnVmnrs_to_Vpqrs(t1(ifvo(1)), fmi(ifoo(1)), 1, 1, & 
            popa, zorb, 1, vrta, zorb, 1, popa, zorb, 1, &
            r1(ifvo(1)), 1, fact, 1.d0)
! write(6,*)'norm of aa 2 r1t1f', nrm2so(nsizeaa, r1(ifvo(1)), 1) 
! write(6,*)'norm of bb 2 r1t1f', nrm2so(nsizebb, r1(ifvo(2)), 1) 
!==BB
 call VpqmnVmnrs_to_Vpqrs(t1(ifvo(2)), fmi(ifoo(2)), 1, 1, & 
            popb, zorb, 1, vrtb, zorb, 1, popb, zorb, 1, &
            r1(ifvo(2)), 1, fact, 1.d0)
! write(6,*)'norm of aa 3 r1t1f', nrm2so(nsizeaa, r1(ifvo(1)), 1) 
! write(6,*)'norm of bb 3 r1t1f', nrm2so(nsizebb, r1(ifvo(2)), 1) 
!
return
end
